package com.edu.web.controller.info;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.edu.common.annotation.Log;
import com.edu.common.core.controller.BaseController;
import com.edu.common.core.domain.AjaxResult;
import com.edu.common.enums.BusinessType;
import com.edu.system.domain.TRechargeRecord;
import com.edu.system.service.ITRechargeRecordService;
import com.edu.common.utils.poi.ExcelUtil;
import com.edu.common.core.page.TableDataInfo;

/**
 * 充值记录Controller
 *
 * @author xxxx
 * @date 2023-12-22
 */
@RestController
@RequestMapping("/system/rechargeRecord")
public class TRechargeRecordController extends BaseController
{
    @Autowired
    private ITRechargeRecordService tRechargeRecordService;

    /**
     * 查询充值记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:rechargeRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(TRechargeRecord tRechargeRecord)
    {
        startPage();
        List<TRechargeRecord> list = tRechargeRecordService.selectTRechargeRecordList(tRechargeRecord);
        return getDataTable(list);
    }

    /**
     * 导出充值记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:rechargeRecord:export')")
    @Log(title = "充值记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TRechargeRecord tRechargeRecord)
    {
        List<TRechargeRecord> list = tRechargeRecordService.selectTRechargeRecordList(tRechargeRecord);
        ExcelUtil<TRechargeRecord> util = new ExcelUtil<TRechargeRecord>(TRechargeRecord.class);
        util.exportExcel(response, list, "充值记录数据");
    }

    /**
     * 获取充值记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:rechargeRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tRechargeRecordService.selectTRechargeRecordById(id));
    }

    /**
     * 新增充值记录
     */
    @PreAuthorize("@ss.hasPermi('system:rechargeRecord:add')")
    @Log(title = "充值记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Valid TRechargeRecord tRechargeRecord)
    {
        tRechargeRecord.setCreateBy(getUsername());
        return toAjax(tRechargeRecordService.insertTRechargeRecord(tRechargeRecord));
    }


    /**
     * 删除充值记录
     */
    @PreAuthorize("@ss.hasPermi('system:rechargeRecord:remove')")
    @Log(title = "充值记录", businessType = BusinessType.DELETE)
	  @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tRechargeRecordService.deleteTRechargeRecordByIds(ids));
    }
}
